<%@page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%><!DOCTYPE HTML>
<html>
<head>
<title>企业名录</title>
<script type="text/javascript">
	$(function() {
		$('#toolbar').toolbar({buttons:[
		    /* {name:'search',iconCls:'icon-search',text:'检索'}, */
           	/* {name:'add',iconCls:'icon-add',text:'添加公司'}, */
       		{name:'edit',iconCls:'icon-edit',text:'修改',disabled:true},
       		{name:'del',iconCls:'icon-del',text:'删除',disabled:true}
      	],handler:handler});
		
		$('#grid').datagrid({
		    url:'/zhaoshang/company/directory/page',pagination:true,singleSelect:true,
		    pageSize:20,
		    rownumbers:true,striped:true,fitColumns:true,fit:true,
		    columns:[[
		    	{field:'id',title:'id'},
		    	{field:'comName',title:'企业名称'},
		    	{field:'tagName',title:'企业类型'},
				{field:'personIncharge',title:'对接人职务'},
				{field:'inchargeTel',title:'联系电话'},
				{field:'comStatus',title:'企业状态',formatter:function(v,r,i){
					var action = '<a>-</a>';
					if(r.comStatus == 1){
						action = '<a>正常</a>';
					}
					if(r.comStatus == 2){
						action = '<a>黑名单</a>';
					}
					if(r.comStatus == 3){
						action = '<a>删除</a>';
					}
					return action;
				}},
				{field:'certificationResult',title:'认证状态',formatter:function(v,r,i){
					var action = '<a>-</a>';
					if(r.certificationResult == 1){
						action = '<a>认证成功</a>';
					}
					if(r.certificationResult == 2){
						action = '<a>认证中</a>';
					}
					if(r.certificationResult == 3){
						action = '<a>认证失败</a>';
					}
					return action;
				}},
				/* {field:'financingStatus',title:'融资状态'}, */
				{field:'staffSize',title:'人员规模'}
				/* {field:'-',title:'操作',formatter:function(v,r,i){
					var action = '<a>删除</a>';
					if(r.comStatus == '3'){
						action = '<a>恢复</a>';
					}
					if(r.certificationResult == '2'){
						action = action + '<a>审核</a>';
					}
					return action;
				}}  */
		    ]],
		    onClickRow:function(i,r) {
				$('#toolbar').toolbar('enableAll');
			}
			,onBeforeLoad:function(param) {
				$('#toolbar').toolbar('search,add,add2');
			},
			view: detailview,
			detailFormatter: function(rowIndex, rowData){
				return '<table><tr>' +
						'<td style="border:0"><img src="images/' + rowData.logUrl + '.png" style="height:50px;"></td>' +
						'<td style="border:0" rowspan=8 >' +rowData.comDescribe+
						'</td>' +
						'</tr></table>';
			}
		});
	});
	function handler() {
		if(this.name == 'search') return toSearch();
		if(this.name == 'add') return toAdd();
		var item = $('#grid').treegrid('getSelected');
		if(!item) return;
		switch(this.name) {
		case 'addSub': toAddSub(item);break;
		case 'edit': toEdit(item);break;
		case 'del': toDel(item);break;
		}
	}
	function toEdit(item) {
		show({code:'zhaoshagn_company_directory_edit',title:'编辑用户信息',iconCls:'icon-edit',uri:'edit?id='+item.id,width:1000,height:600,
			options : {
				success : function(data) { 
					$('#grid').datagrid('reload'); 
				}
			}
		});
	}
	function toDel(item) {
		$confirm('您确定要删除“'+item.modelName+'”模块信息吗？',function() {
			$.post('delete?id='+item.id,function(r) {
				if(r.code <= 0) return $error(r.msg);
				$('#grid').datagrid('reload');
				$prompt('删除成功');
			},'json');
		});
	}
</script>
</head>
<body>
	<div id="toolbar" class="toolbar"></div>
	<div class="easyui-layout" data-options="fit:true">
	    <div data-options="region:'center',border:false" style="padding-bottom: 33px">
			<table id="grid"></table>
	    </div>
    </div>
</body>
</html>